﻿namespace Work
{
    class Order
    {
        public int number;
        public string name;
        public string client;
        public int account;
        public Order(int number, string name, string client, int account)
        {
            this.number = number; this.name = name; this.client = client; this.account = account;
        }
        public override string ToString()
        {
            return "number:" + number + " name:" + name + " client" + client + " account:" + account;
        }
        public override bool Equals(Object obj)
        {
            Order order = obj as Order;
            return (this.number == order.number) && (this.name == order.name) && (this.client == order.client) && (this.account == order.account);
        }
    }

    class OrderDetails
    {

    }
    class orderlistervice
    {
        List<Order> orderlist = new List<Order>();


        public void AddOrder(int onumber, string oname, string oclient, int oaccount)
        {
            orderlist.Add(new Order(onumber, oname, oclient, oaccount));
            var orders = from x in orderlist
                         select x;
            orderlist = orderlist.OrderBy(x => x.number).ToList();
        }


        public void DeleteOrder(string  string1)
        {
            var  query1=from oorder in  orderlist
                        where oorder.name==string1||oorder.client==string1
                        select oorder;
            if (query1==null) Console.WriteLine("删除失败");
            orderlist = orderlist.Except(query1).ToList();
            var orders = from x in orderlist
                         select x;
            orderlist = orderlist.OrderBy(x => x.number).ToList();
        }

        public void DeleteOrder(int  num1)
        {
            var query1 = from oorder in orderlist
                         where oorder.number == num1 || oorder.account == num1
                         select oorder;
            if (query1 == null) Console.WriteLine("删除失败");
            orderlist = orderlist.Except(query1).ToList();
            var orders = from x in orderlist
                         select x;
            orderlist = orderlist.OrderBy(x => x.number).ToList();
        }

        public void Search(int onenumber)
        {
            var query1 = from oneorder in orderlist
                         where oneorder.number == onenumber||oneorder.account == onenumber
                         orderby oneorder.account
                         select oneorder;
            List<Order> result = query1.ToList();
            foreach (var order in result)
            {
                Console.WriteLine(order);
            }


             void Search(string oname)
            {
                var query1 = from oneorder in orderlist
                             where oneorder.name == oname||oneorder.client==oname
                             orderby oneorder.account
                             select oneorder;
                List<Order> result = query1.ToList();
                foreach (var order in result)
                {
                    Console.WriteLine(order);
                }

            }





        }

        class main
        {
            public static void Main()
            {

            }

        }
    }
}